package com.ktwlsoft.fundmanage.domain.entity;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * 数据字典
 *
 * @author Name on 2019/9/4 15:51
 * @version 1.0
 */
@Entity
@Table(name = "data_dictionary")
@Setter
@Getter
@ApiModel("数据字典-DataDictionary")
public class DataDictionary extends BaseEntity{

    /**主键*/
    @ApiModelProperty("主键")
    @Id
    @Column(name = "id",columnDefinition = "bigint(30) NOT NULL COMMENT '主键'")
    private Long id;

    /**父级id*/
    @ApiModelProperty("父级id")
    @Column(name = "parent_id",columnDefinition = "bigint(30) DEFAULT NULL COMMENT '父级id'")
    private Long parentId;

    /**键*/
    @ApiModelProperty("键")
    @Column(name = "dic_Key",columnDefinition = "varchar(100) DEFAULT NULL COMMENT '键'")
    @Size(max = 100, message = "键参数超长")
    private String dicKey;

    /**值*/
    @ApiModelProperty("值")
    @Column(name = "dic_Value",columnDefinition = "Text DEFAULT NULL COMMENT '值'")
    private String dicValue;

    /**状态:1.(used)启用,2.(stoped)停用,3.(deleted)删除*/
    @ApiModelProperty("状态")
    @Enumerated(EnumType.STRING)
    private DicState state;

    /**创建人id*/
    @ApiModelProperty("创建人id")
    @Column(name = "creator_id",columnDefinition = "varchar(100) DEFAULT NULL COMMENT '创建人id'")
    @Size(max = 100, message = "创建人id参数超长")
    private String creatorId;

    /**创建人名*/
    @ApiModelProperty("创建人名")
    @Column(name = "creator_name",columnDefinition = "varchar(100) DEFAULT NULL COMMENT '创建人名'")
    @Size(max = 100, message = "创建人名参数超长")
    private String creatorName;

    /**更新人名*/
    @ApiModelProperty("更新人名")
    @Column(name = "update_name", columnDefinition = "varchar(100) DEFAULT NULL COMMENT '更新人名'")
    @Size(max = 100, message = "更新人名参数超长")
    private String updateName;

    /**更新人id*/
    @ApiModelProperty("更新人id")
    @Column(name = "update_id", columnDefinition = "varchar(100) DEFAULT NULL COMMENT '更新人id'")
    @Size(max = 100, message = "更新人id参数超长")
    private String updateId;

    /**子集合*/
    @ApiModelProperty("子集合")
    @Transient
    private List<DataDictionary> dataDictionaries;

    /**
     * 字典状态
     */
    public enum DicState{
        /**
         * 使用中
         */
        USING,
        /**
         * 停用
         */
        STOP,
        /**
         * 删除
         */
        DELETED;
    }
}